XMODEM Transmit Form1 Label1 Uploading: filename filename Label2 Bytes: So Far/Total: bytes bytes Label3 Errors: Recent/Total: errors errors CommandAbort Abort Form_Click Form_Paint nextpacket checksum: filenumber[ filename3 caption serialbinary GetTickCountB timeout SerialRead CTRLZ serialwrite ErrorTotal ErrorRecent UpdateStats errors errorsrecent errorstotal BytesTotal BytesSoFar bytesE CommandAbort_Click AbortFlag FALSE CanCount InterLock BufSizeg waitack_ GetResponse selecte FillBuffer buffer fileno Received pring Num2Read TX.FRMM This is the code to handle the XMODEM Transmission Charles McGuinness [76701,11] Constants used in the XMODEM protocol. See RX.FRM for definitionsn In case of parity Form_Paint This is the routine we use to transmit a file.... Next packet to send temp var to comput checksum File we're reading from Buffer to hold data we're sending Counter to time out receivers Temp var to hold a byte of data How much data read How many CANs (^X) in a row To prevent re-entrancya Are we already running? If so, bail out Open filename.caption For Input Access Read As filenumber Unable to open " How much to send in total Before we start waiting for the first NAK, we should read and discard any data already buffered. Otherwise, we might find three NAKs (for example) waiting for us already that could confuse the protocol. Wait for first NAK to start us off Receiver never started Receiver aborted Main Transmitting loop On each iteration of this loop, another (new) buffer is sentK OK, let's send the next packet of data! Get the data from the filec On each iteration of this loop, the same buffer is sent Was there no more data??l No data!s Tell receiver we're done! Write the data packet Wait for ACK/NAK Receiver timed out Receiver aborted Too Many Errors" UpdateStats Updates the form with the current status CommandAbort_Click The user has clicked the abort button.... GetResponse This function gets the handshake from the remote computer.. The handshake can be either:: An ACK charactera A NAK character Two CANs in a row The routine will return the character recieved (i.e., ACK, NAK, or CAN) or will return -1 if the link times out.. Data received When we started waiting Counter for two CANs in a row Debug.Print "Response is abort"p Debug.Print "Response is time out" Debug.Print "Response is CAN" Is the other end aborting the transfer? Debug.Print "Response is ACK/NAK ("; Asc(byte); ")"i FillBuffer